﻿using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;

namespace ZipSpace
{
	public partial class ExceptionWindow : ChildWindow
	{
		public ExceptionWindow(Exception exception)
		{
			InitializeComponent();

			Debug.WriteLine(exception);
			this.DataContext = exception;
		}

        private void CloseButton_Click(object sender, RoutedEventArgs e)
		{
			this.DialogResult = false;
		}

		private void CopyButton_Click(object sender, RoutedEventArgs e)
		{
            try
            {
                this.DialogResult = false;

                if (this.DataContext != null)
                    Clipboard.SetText(this.DataContext.ToString());
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                MessageBox.Show("Unable to set clipboard text.");
            }
		}

		public static void Show(Exception exception)
		{
			new ExceptionWindow(exception).Show();
		}
	}
}

